﻿using System;

class SubsetSum
{
    static void Main(string[] args)
    {
        int[] arr = { 2, 1, 2, 4, 3, 5, 2, 6 };
        int s = 17;
        int sum = 0;

        bool[] check = new bool[8];
        for (int i = 0; i < arr.Length; i++)
        {
            Console.Write("{0} ", arr[i]);
        }
        Console.WriteLine();
        for (int i = 0; i < arr.Length; i++)
        {
            sum = sum + arr[i];
            if (sum == s)
            {
                check[i] = true;
            }
            else if (sum > s)
            {
                sum = sum - arr[i];
                check[i] = false;
            }
            else if (sum < s)
            {
                check[i] = true;
            }
        }
        if (sum == s)
        {
            for (int i = 0; i < arr.Length; i++)
            {
                if (check[i] == true)
                {
                    Console.Write("{0} ", arr[i]);
                }
                else if (check[i] == false)
                {
                    Console.Write(" ");
                }
            }
        }
        else
        {
            Console.WriteLine("The is no such a subset sum");
        }
    }
}



